package com.yu.smsinterceptor.service;

import com.yu.smsinterceptor.dao.PhoneDao;
import com.yu.smsinterceptor.mode.Phone;

import java.util.ArrayList;
import java.util.List;

public class PhoneService {

    private PhoneDao dao = new PhoneDao();

    public void save(Phone m) {
        dao.save(m);
    }

    public Phone get(Long id) {
        return dao.get(id);
    }

    public List<Phone> list() {
        return dao.list();
    }

    public void delete(Long id) {
        dao.delete(id);
    }

    public List<Long> listPhoneNumber() {
        List<Long> list = new ArrayList<>();
        List<Phone> phones = list();
        for (Phone phone : phones) {
            list.add(phone.getPhoneNumber());
        }

        return list;
    }
}
